package com.okb.service;

import com.alibaba.fastjson.JSON;
import com.okb.dto.LoginArgsDto;
import com.okb.dto.RequestTemplateDto;
import com.okb.service.impl.subscribe.BtcSocketClientExample;
import com.okb.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * Description:
 * Author: hcxu
 * Time: 2024/11/18 3:05 PM
 */
@Slf4j
public class ClientConnection {
    public static void main(String[] args) throws Exception {
        System.out.println(sendRestRequest());
    }

    public static String sendRestRequest() throws Exception {
        RequestTemplateDto requestTemplateDto = new RequestTemplateDto();
        requestTemplateDto.setOp("login");
        LoginArgsDto loginArgsDto = new LoginArgsDto();
        loginArgsDto.setApiKey(HttpUtils.apiKey);
        String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
        String method = "/api/v5/account/balance";
//        StringBuffer signBuffer = new StringBuffer();
//        signBuffer.append(timestamp).append("GET").append(method);
//        String sign = HttpUtils.encryptHMACSHA256(signBuffer.toString(), HttpUtils.secretKey);
//        loginArgsDto.setSign(sign);
//        loginArgsDto.setPassphrase(HttpUtils.passphrase);
//        loginArgsDto.setTimestamp(timestamp);
//        requestTemplateDto.setArgs(Arrays.asList(loginArgsDto));
//        String jsonBody = JSON.toJSONString(requestTemplateDto);
        Map<String, String> header = HttpUtils.getHeader(method, "GET", null);
        String result = HttpUtils.getRequest(HttpUtils.method_pre + method, null, header);
        return result;
    }
    public static void sendSocket(){

    }
}
